﻿using agsXMPP;
using agsXMPP.protocol.client;
using agsXMPP.Xml.Dom;

namespace sharpxbot.Core.Connection
{
    public delegate void SocketDataHandler(int bytesCount);

    public interface IConnection
    {
        XmppConnectionState State { get; }

        XmppConnectionStateHandler ConnectionStateChanged { get; set; }
        ObjectHandler OnLogin { get; set; }
        ObjectHandler OnClose { get; set; }
        ObjectHandler OnSessionStarted { get; set; }
        PresenceHandler OnPresence { get; set; }
        MessageHandler OnMessage { get; set; }
        SocketDataHandler OnSocketWrite { get; set; }
        SocketDataHandler OnSocketRead { get; set; }

        /// <summary>
        /// Opens connection. If it isn't closed does nothing
        /// </summary>
        void Open();

        /// <summary>
        /// Closes connection.
        /// </summary>
        void Close();

        void Send(Element msg);

        void Send(string xml);
    }
}
